#ifndef DHD_S_FUSE_BACKEND_H
#define DHD_S_FUSE_BACKEND_H

#include <string>
#include "dhd_fs.pb.h"
#include "buffers.h"

namespace dhd
{
namespace server
{
      
class FuseBackend
{
   
   int be_getattr    (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_access     (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_readlink   (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_readdir    (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_mknod      (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_mkdir      (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_unlink     (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_rmdir      (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_symlink    (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_rename     (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_link       (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_chmod      (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_chown      (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_truncate   (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_utimens    (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_open       (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_read       (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_write      (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_statfs     (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_release    (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_fsync      (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_setxattr   (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_getxattr   (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_listxattr  (const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   int be_removexattr(const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);

   
   int dhd_server_root(const std::string & path, ToServer & request, ToClient & reply, PBuffer & inbuff, PBuffer & outbuff);
   
   const std::string root;


 public:
   
   FuseBackend( const std::string & _root ) : root(_root) 
   {}
       
   
   PBuffer handle_request(ToServer & request, ToClient & reply, PBuffer & inbuff );
};

   
} // end namespace dhd::server
} // end namespace dhd

   
#endif